package com.tmt.im.manager.controller.api;


import com.tmt.im.common.enums.IMRoleEnum;
import com.tmt.im.jpa.entity.IMUserRole;
import com.tmt.im.manager.controller.vo.CustomerInfoVo;
import com.tmt.im.manager.service.IMUserService;
import com.tmt.springboot.common.restful.ExecuteResult;
import com.tmt.springboot.common.restful.IExecuteResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.concurrent.CompletableFuture;

/**
 * 客服相关接口
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/9/20 9:59
 * @Version 1.0
 **/
@Async("asyncTaskExecutor")
@Tag(name = "客服相关接口", description = "客服相关接口")
@RestController
@RequestMapping("${api-url-prefix}/customer")
public class CustomerController {

    private final IMUserService imUserService;

    public CustomerController(IMUserService imUserService){
        this.imUserService = imUserService;
    }

    @Operation(summary = "获取客服账号信息",
            description = "获取客服账号信息",
            operationId = "getDefaultCustomerInfo")
    @GetMapping("/info")
    public CompletableFuture<IExecuteResult<CustomerInfoVo>> getDefaultCustomerInfo(Principal principal) {
        IExecuteResult<CustomerInfoVo> result = imUserService.findFirstByRole(IMRoleEnum.IM_ROLE_CUSTOMER);
        return CompletableFuture.completedFuture(result);
    }

}
